from time import sleep
import uiautomation
import pyautogui


class Xiyaochengyaochufang():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    xiyaochengyaochufang = his.TabControl(AutomationId='tabZhenliao', ClassName='TabControl').TabItemControl(Name='西药成药处方', ClassName='TabItem')  # 西药成药处方


# 西药成药处方
    #药品名称
    yaopinmingcheng1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 2',ClassName="DataGridCell", foundIndex=1)
    yaopinmingcheng1_1 = yaopinmingcheng1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 西药药品名称输入框

    yaopinmingcheng2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 2',ClassName="DataGridCell", foundIndex=2)
    yaopinmingcheng2_1 = yaopinmingcheng2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 西药药品名称输入框

    yaopinmingcheng3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 2',ClassName="DataGridCell", foundIndex=3)
    yaopinmingcheng3_1 = yaopinmingcheng3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 西药药品名称输入框

    yaopinmingcheng4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 2',ClassName="DataGridCell", foundIndex=4)
    yaopinmingcheng4_1 = yaopinmingcheng4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 西药药品名称输入框

    yaopinmingcheng5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 2',ClassName="DataGridCell", foundIndex=5)
    yaopinmingcheng5_1 = yaopinmingcheng5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 西药药品名称输入框





    #次数
    cishu1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=1)
    cishu1_1 = cishu1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框

    cishu2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=2)
    cishu2_1 = cishu2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框

    cishu3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=3)
    cishu3_1 = cishu3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框

    cishu4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=4)
    cishu4_1 = cishu4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框

    cishu5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=5)
    cishu5_1 = cishu5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框




    #用法
    yongfa1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 8',ClassName="DataGridCell",foundIndex=1)
    yongfa1_1 = yongfa1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框

    yongfa2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 8',ClassName="DataGridCell",foundIndex=2)
    yongfa2_1 = yongfa2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框

    yongfa3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 8',ClassName="DataGridCell",foundIndex=3)
    yongfa3_1 = yongfa3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框

    yongfa4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 8',ClassName="DataGridCell",foundIndex=4)
    yongfa4_1 = yongfa4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框

    yongfa5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 8',ClassName="DataGridCell",foundIndex=5)
    yongfa5_1 = yongfa5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框


    #皮试
    pishi1  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 3',ClassName="DataGridCell",foundIndex=1)
    pishi1_1 = pishi1.CheckBoxControl(ClassName='CheckBox')  #皮试

    pishi2  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 3',ClassName="DataGridCell",foundIndex=2)
    pishi2_1 = pishi2.CheckBoxControl(ClassName='CheckBox')  #皮试

    pishi3  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 3',ClassName="DataGridCell",foundIndex=3)
    pishi3_1 = pishi3.CheckBoxControl(ClassName='CheckBox')  #皮试

    pishi4  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 3',ClassName="DataGridCell",foundIndex=4)
    pishi4_1 = pishi4.CheckBoxControl(ClassName='CheckBox')  #皮试

    pishi5  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 3',ClassName="DataGridCell",foundIndex=5)
    pishi5_1 = pishi5.CheckBoxControl(ClassName='CheckBox')  #皮试

    #免试
    mianshi1  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 15',ClassName="DataGridCell",foundIndex=1)
    mianshi1_1 = mianshi1.CheckBoxControl(ClassName='CheckBox')  #皮试

    mianshi2  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 15',ClassName="DataGridCell",foundIndex=2)
    mianshi2_1 = mianshi2.CheckBoxControl(ClassName='CheckBox')  #皮试

    mianshi3  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 15',ClassName="DataGridCell",foundIndex=3)
    mianshi3_1 = mianshi3.CheckBoxControl(ClassName='CheckBox')  #皮试

    mianshi4  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 15',ClassName="DataGridCell",foundIndex=4)
    mianshi4_1 = mianshi4.CheckBoxControl(ClassName='CheckBox')  #皮试

    mianshi5  = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 15',ClassName="DataGridCell",foundIndex=5)
    mianshi5_1 = mianshi5.CheckBoxControl(ClassName='CheckBox')  #皮试







#西药成药处方
    #点击西药成药处方
    def click_xycycf_btn(self):
        self.xiyaochengyaochufang.Click()
        sleep(1)



        #选择药品名称
    def input_ypmc1(self,ypmc1):
            self.yaopinmingcheng1.DoubleClick()
            sleep(0.5)
            self.yaopinmingcheng1_1.SendKeys(ypmc1)
            pyautogui.press('enter')

    def input_ypmc2(self,ypmc2):
            self.yaopinmingcheng2.DoubleClick()
            sleep(0.5)
            self.yaopinmingcheng2_1.SendKeys(ypmc2)
            pyautogui.press('enter')

    def input_ypmc3(self,ypmc3):
            self.yaopinmingcheng3.DoubleClick()
            sleep(0.5)
            self.yaopinmingcheng3_1.SendKeys(ypmc3)
            pyautogui.press('enter')

    def input_ypmc4(self,ypmc4):
            self.yaopinmingcheng4.DoubleClick()
            sleep(0.5)
            self.yaopinmingcheng4_1.SendKeys(ypmc4)
            pyautogui.press('enter')

    def input_ypmc5(self,ypmc5):
            self.yaopinmingcheng5.DoubleClick()
            sleep(0.5)
            self.yaopinmingcheng5_1.SendKeys(ypmc5)
            pyautogui.press('enter')


    def input_ypmc(self):
        self.yaopinmingcheng1.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng1_1.SendKeys("0.9%氯化钠注射液")
        pyautogui.press('enter')

        self.yaopinmingcheng2.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng2_1.SendKeys("5%葡萄糖注射液")
        pyautogui.press('enter')

        self.yaopinmingcheng3.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng3_1.SendKeys("阿奇霉素胶囊")
        pyautogui.press('enter')

        self.yaopinmingcheng4.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng4_1.SendKeys("阿归养血颗粒")
        pyautogui.press('enter')

        self.yaopinmingcheng5.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng5_1.SendKeys("奥硝唑分散片")
        pyautogui.press('enter')

    #选择次数
    def input_cs1(self,cs1):
            self.cishu1.DoubleClick()
            self.cishu1_1.SendKeys(cs1)
            pyautogui.press('enter')

    def input_cs2(self,cs2):
            self.cishu2.DoubleClick()
            self.cishu2_1.SendKeys(cs2)
            pyautogui.press('enter')

    def input_cs3(self,cs3):
            self.cishu3.DoubleClick()
            self.cishu3_1.SendKeys(cs3)
            pyautogui.press('enter')

    def input_cs4(self,cs4):
            self.cishu4.DoubleClick()
            self.cishu4_1.SendKeys(cs4)
            pyautogui.press('enter')

    def input_cs5(self,cs5):
            self.cishu5.DoubleClick()
            self.cishu5_1.SendKeys(cs5)
            pyautogui.press('enter')



    def input_cs(self):
        self.cishu1.DoubleClick()
        self.cishu1_1.SendKeys('每天一次')
        pyautogui.press('enter')

        self.cishu2.DoubleClick()
        self.cishu2_1.SendKeys('每天二次')
        pyautogui.press('enter')

        self.cishu3.DoubleClick()
        self.cishu3_1.SendKeys('每天三次')
        pyautogui.press('enter')

        self.cishu4.DoubleClick()
        self.cishu4_1.SendKeys('每四小时一次')
        pyautogui.press('enter')

        self.cishu5.DoubleClick()
        self.cishu5_1.SendKeys('每周一次')
        pyautogui.press('enter')








        #选择用法
    def input_yf1(self):
            self.yongfa1.DoubleClick()
            self.yongfa1_1.SendKeys("肌肉注射")
            pyautogui.press('enter')

    def input_yf2(self):
            self.yongfa2.DoubleClick()
            self.yongfa2_1.SendKeys("静脉滴注")
            pyautogui.press('enter')

    def input_yf3(self):
            self.yongfa3.DoubleClick()
            self.yongfa3_1.SendKeys("口服")
            pyautogui.press('enter')

    def input_yf4(self):
            self.yongfa4.DoubleClick()
            self.yongfa4_1.SendKeys("口服")
            pyautogui.press('enter')

    def input_yf5(self):
            self.yongfa5.DoubleClick()
            self.yongfa5_1.SendKeys("口服")
            pyautogui.press('enter')

    def input_yf(self):
        self.yongfa1.DoubleClick()
        self.yongfa1_1.SendKeys("肌肉注射")
        pyautogui.press('enter')

        self.yongfa2.DoubleClick()
        self.yongfa2_1.SendKeys("静脉滴注")
        pyautogui.press('enter')

        self.yongfa3.DoubleClick()
        self.yongfa3_1.SendKeys("口服")
        pyautogui.press('enter')

        self.yongfa4.DoubleClick()
        self.yongfa4_1.SendKeys("口服")
        pyautogui.press('enter')

        self.yongfa5.DoubleClick()
        self.yongfa5_1.SendKeys("口服")
        pyautogui.press('enter')



    #皮试
    def choose_ps1(self):
        self.pishi1.DoubleClick()
        self.pishi1_1.Click()

    def choose_ps2(self):
        self.pishi2.DoubleClick()
        self.pishi2_1.Click()

    def choose_ps3(self):
        self.pishi3.DoubleClick()
        self.pishi3_1.Click()

    def choose_ps4(self):
        self.pishi4.DoubleClick()
        self.pishi4_1.Click()

    def choose_ps5(self):
        self.pishi5.DoubleClick()
        self.pishi5_1.Click()

    #免试
    def choose_ms1(self):
        self.mianshi1.DoubleClick()
        self.mianshi1_1.Click()

    def choose_ms2(self):
        self.mianshi2.DoubleClick()
        self.mianshi2_1.Click()

    def choose_ms3(self):
        self.mianshi3.DoubleClick()
        self.mianshi3_1.Click()

    def choose_ms4(self):
        self.mianshi4.DoubleClick()
        self.mianshi4_1.Click()

    def choose_ms5(self):
        self.mianshi5.DoubleClick()
        self.mianshi5_1.Click()




# 输入第一排数据
    def input_xy1(self,ypmc,cs,yf):
        self.yaopinmingcheng1.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng1_1.SendKeys(ypmc)
        pyautogui.press('enter')
        self.cishu1.DoubleClick()
        self.cishu1_1.SendKeys(cs)
        pyautogui.press('enter')
        self.yongfa1.DoubleClick()
        self.yongfa1_1.SendKeys(yf)
        pyautogui.press('enter')
#输入第二排数据
    def input_xy2(self,ypmc,cs,yf):
        self.yaopinmingcheng2.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng2_1.SendKeys(ypmc)
        pyautogui.press('enter')
        self.cishu2.DoubleClick()
        self.cishu2_1.SendKeys(cs)
        pyautogui.press('enter')
        self.yongfa2.DoubleClick()
        self.yongfa2_1.SendKeys(yf)
        pyautogui.press('enter')
# 输入第三排数据
    def input_xy3(self, ypmc, cs, yf):
        self.yaopinmingcheng3.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng3_1.SendKeys(ypmc)
        pyautogui.press('enter')
        self.cishu3.DoubleClick()
        self.cishu3_1.SendKeys(cs)
        pyautogui.press('enter')
        self.yongfa3.DoubleClick()
        self.yongfa3_1.SendKeys(yf)
        pyautogui.press('enter')
# 输入第四排数据
    def input_xy4(self, ypmc, cs, yf):
        self.yaopinmingcheng4.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng4_1.SendKeys(ypmc)
        pyautogui.press('enter')
        self.cishu4.DoubleClick()
        self.cishu4_1.SendKeys(cs)
        pyautogui.press('enter')
        self.yongfa4.DoubleClick()
        self.yongfa4_1.SendKeys(yf)
        pyautogui.press('enter')

# 输入第五排数据
    def input_xy5(self,ypmc,cs,yf):
        self.yaopinmingcheng5.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng5_1.SendKeys(ypmc)
        pyautogui.press('enter')
        self.cishu5.DoubleClick()
        self.cishu5_1.SendKeys(cs)
        pyautogui.press('enter')
        self.yongfa5.DoubleClick()
        self.yongfa5_1.SendKeys(yf)
        pyautogui.press('enter')
